package com.chen.seckill.rabbitmq;

import com.chen.seckill.config.RabbitMQConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class MQSender {

    @Resource
    private RabbitTemplate rabbitTemplate;


    /**
     * 交换机
     */
    private static final String EXCHANGE = "seckillExchange";

    /**
     * 发送秒杀信息
     * @param message
     */
    public void sendSeckillMessage(String message){
        log.info("发送消息: "+message);
        rabbitTemplate.convertAndSend(EXCHANGE,"seckill.message",message);
    }
}
